home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / misc / football / user / gamesplayed.rexx < prev    next >
OS/2 REXX Batch file  |  1999-02-03  |  5KB  |  175 lines

  1. /* ***********************************************************************
  2.  
  3.    GAMES PLAYED PROGRAM FOR FOOTBALL REXX SUITE
  4.   ----------------------------------------------
  5.                    Copyright  Mark Naughton 1997
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       050197   First release.
  11.            060197   Added check so that it exits if the teams play each
  12.                     other more than twice.
  13.            110197   Forgot to initialise the variable used above. Name
  14.                     changed from 'GamesToBePlayed' to 'GamesPlayed'.
  15.            110197   Now shows all games played by selected team.
  16.            170197   Fixed bug where it displayed the team selected
  17.                     instead of skipping it.
  18.            151297   Now shows selected team's score first in Away matches
  19.                     as well. Tidied display.
  20.  
  21. **************************************************************************
  22.  
  23. Procedure
  24. ---------
  25.  
  26. 1. Check files exist. Read Teams.df datafile and store teams.
  27. 3. Open Schedule datafile.
  28. 4. Use selected team against either HOME or AWAY team and store the score
  29.    if a match has been played. Otherwise increment matches_to_play.
  30. 5. Close file. Display data then exit...
  31.  
  32. ************************************************************************** */
  33. PARSE ARG league_stuff
  34.  
  35. version      = 1
  36. input_file   = '.df'
  37. input2_file  = '.sf'
  38. title        = '*LEAGUE_NAME='
  39. playeo       = '*PLAY_OTHER='
  40. separator    = '*'
  41. teams.       = '???'
  42. teams2.      = '???'
  43. counter      = 0
  44. not_played   = '__   __'
  45. home.        = '???'
  46. away.        = '???'
  47. numplay      = 2
  48.  
  49.  
  50. parse var league_stuff league_file search_team
  51. league_file = "Data/" || league_file
  52.  
  53. if exists(league_file || input_file) = 0  then exit
  54. if exists(league_file || input2_file) = 0 then exit
  55.  
  56. if open(datafile,league_file || input_file,'r') then do
  57.    do while ~eof(datafile)
  58.       line = readln(datafile)
  59.       if pos(title,line) > 0 then
  60.          league_title = delstr(line,1,13)
  61.       if pos(playeo,line) > 0 then
  62.          numplay = delstr(line,1,12)
  63.       if pos(separator,line) = 0 then do
  64.          line = strip(line)
  65.          if counter = 0 then do
  66.             teams.1 = line
  67.             counter = 1
  68.          end
  69.          else do
  70.             counter       = counter + 1
  71.             teams.counter = line
  72.          end
  73.       end
  74.    end
  75.    close(datafile)
  76.  
  77.    if numplay > 2 then do
  78.       say
  79.       say "ERROR :    (GamesPlayed)"
  80.       say
  81.       say "This routine only works when each team play each other twice."
  82.       exit
  83.    end
  84.  
  85.    sel=-1
  86.    search_team = strip(search_team)
  87.    do i=1 to counter
  88.       if pos(search_team,teams.i) > 0 then
  89.          sel = i
  90.    end
  91.    i   = 0
  92.    mtp = 0
  93.    if sel > 0 then do
  94.       if open(datafile,league_file || input2_file,'r') then do
  95.          do while ~eof(datafile)
  96.             line = readln(datafile)
  97.             if pos(separator,line) = 0 then do
  98.                home_team = strip(substr(line,1,30))
  99.                goals_for = strip(substr(line,32,2))
  100.                goals_aga = strip(substr(line,37,2))
  101.                away_team = strip(substr(line,41,30))
  102.  
  103.                strng = strip(teams.sel)
  104.                if strng = home_team then do
  105.                   do i=1 to counter
  106.                      if away_team = teams.i then do
  107.                         if pos(not_played,line) > 0 then
  108.                            home.i = '-'
  109.                         else do
  110.                            home.i = goals_for || "-" || goals_aga
  111.                            mtp = mtp + 1
  112.                         end
  113.                      end
  114.                   end
  115.                end
  116.                if strng = away_team then do
  117.                   do i=1 to counter
  118.                      if home_team = teams.i then do
  119.                         if pos(not_played,line) > 0 then
  120.                            away.i = '-'
  121.                         else do
  122.                            away.i = goals_aga || "-" || goals_for
  123.                            mtp = mtp + 1
  124.                         end
  125.                      end
  126.                   end
  127.                end
  128.             end
  129.          end
  130.          close(datafile)
  131.       end
  132.       else do
  133.          say
  134.          say "ERROR :    (GamesPlayed)"
  135.          say
  136.          say "Cannot read '"league_file || input2_file"' datafile."
  137.          exit
  138.       end
  139.  
  140.       say
  141.       say center("Games Played in '"league_title"'",78)
  142.       say "-------------------------------------------------------------------------------"
  143.       say
  144.       say "Team: "teams.sel"   (Team's score is ALWAYS FIRST)"
  145.       say
  146.       say
  147.       say "     Home      Away       Team"
  148.       say "     ----      ----       ----"
  149.       do i=1 to counter
  150.          if pos(teams.sel,teams.i) = 0 then
  151.             say "     "left(home.i,7)"   "left(away.i,7)"    "teams.i
  152.       end
  153.       say
  154.       say "     Matches Played: "mtp
  155.       say
  156.       say "-------------------------------------------------------------------------------"
  157.       say
  158.    end
  159.    else do
  160.       say
  161.       say "ERROR :    (GamesPlayed)"
  162.       say
  163.       say "Incorrect team. '"search_team"' cannot be found in this"
  164.       say "league."
  165.       exit
  166.    end
  167. end
  168. else do
  169.    say
  170.    say "ERROR :    (GamesPlayed)"
  171.    say
  172.    say "Cannot read '"league_file || input_file"' datafile."
  173. end
  174.  
  175. exit